// 基础配置
export const config = {
  // API 基础URL
  apiBaseUrl: import.meta.env.VITE_API_BASE_URL || 'http://localhost:3001/api/v1',
  
  // 上传相关URL
  uploadUrl: (import.meta.env.VITE_API_BASE_URL || 'http://localhost:3001/api/v1') + '/upload/image',
  uploadBaseUrl: import.meta.env.VITE_UPLOAD_BASE_URL || 'http://localhost:3001',
  
  // 应用配置
  appName: '学习网站管理系统',
  version: '1.0.0',
  
  // HTTP 请求配置
  timeout: 10000,
  retryConfig: {
    maxRetries: 3,
    retryDelay: 1000 // 1秒
  }
}

// 文件上传配置
export const fileConfig = {
  // 支持的图片类型
  supportedImageTypes: [
    'image/jpeg',
    'image/jpg', 
    'image/png',
    'image/gif',
    'image/webp'
  ],
  
  // 支持的视频类型
  supportedVideoTypes: [
    'video/mp4',
    'video/webm',
    'video/ogg'
  ],
  
  // 支持的文档类型
  supportedDocumentTypes: [
    'application/pdf',
    'application/msword',
    'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
    'text/plain'
  ],
  
  // 文件大小限制（字节）
  maxFileSize: 10 * 1024 * 1024, // 10MB
  maxImageSize: 5 * 1024 * 1024,  // 5MB
  maxVideoSize: 50 * 1024 * 1024, // 50MB
  maxDocumentSize: 10 * 1024 * 1024, // 10MB
  
  // 批量上传限制
  maxUploadCount: 10,
  
  // 图片质量压缩
  imageQuality: 0.8,
  
  // 缩略图尺寸
  thumbnailSizes: {
    small: { width: 150, height: 100 },
    medium: { width: 300, height: 200 },
    large: { width: 600, height: 400 }
  }
}

// API 端点配置
export const apiEndpoints = {
  // 文件管理
  files: {
    list: (type: string) => `/upload/list/${type}`,
    single: '/upload/single',
    multiple: '/upload/multiple',
    delete: (type: string, filename: string) => `/upload/${type}/${filename}`
  },
  
  // 文档管理
  docs: {
    categories: '/docs/categories',
    list: '/docs/list',
    create: '/docs/create',
    update: (id: number) => `/docs/${id}`,
    delete: (id: number) => `/docs/${id}`
  },
  
  // 用户管理
  users: {
    list: '/users/list',
    create: '/users/create',
    update: (id: number) => `/users/${id}`,
    delete: (id: number) => `/users/${id}`
  },

  // 代码示例相关
  CODE_EXAMPLES: '/codeExamples',
  CODE_EXAMPLES_STATS: '/codeExamples/stats',
  CODE_EXAMPLES_BATCH: '/codeExamples/batch',

  // 文件上传相关
  UPLOAD: '/upload',
  UPLOAD_IMAGE: '/upload/image',
  UPLOAD_VIDEO: '/upload/video', 
  UPLOAD_DOCUMENT: '/upload/document',
  UPLOAD_MULTIPLE: '/upload/multiple',
  UPLOAD_IMAGES: '/upload/images',
  
  // 课程相关
  LESSONS: '/lessons',
  LESSONS_FEATURED: '/lessons/featured',
  LESSONS_RECENT: '/lessons/recent',
  LESSON_BY_SLUG: (slug: string) => `/lessons/slug/${slug}`,
  LESSON_LIKE: (id: number) => `/lessons/${id}/like`,
  
  // 分类相关
  CATEGORIES: '/categories',
  CATEGORIES_TREE: '/categories/tree',
  
  // 标签相关
  TAGS: '/tags',
  
  // 用户认证相关
  LOGIN: '/auth/login',
  LOGOUT: '/auth/logout',
  PROFILE: '/auth/profile',
  
  // 管理员相关
  ADMIN_USERS: '/admin/users',
  ADMIN_STATS: '/admin/stats'
}

// 环境配置
export const env = {
  isDevelopment: import.meta.env.DEV,
  isProduction: import.meta.env.PROD,
  mode: import.meta.env.MODE
}

// 默认导出所有配置
export default {
  config,
  fileConfig,
  apiEndpoints,
  env
} 